package com.qnnu.studenttravelsystem.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qnnu.studenttravelsystem.entity.Student;
import com.qnnu.studenttravelsystem.service.impl.StudentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhongge
 * @since 2025-11-20
 */
@RestController
@RequestMapping("/api")
public class StudentController {
    @Autowired
    private StudentServiceImpl studentService;

    //根据班级id查询出学生信息
    @GetMapping("/student/list")
    public List<Student> getStudentsByClass(@RequestParam Long classId) {
        QueryWrapper<Student> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("class_id",classId);
        return studentService.list(queryWrapper);
    }
}
